<%@ page language="java" import="java.util.*" contentType="text/html"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${projectName}</title>
<script type="text/javascript"
	src='<c:url value="/js/boot.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style type="text/css">
body, html {
	width: 100%;
	height: 100%;
	margin: 0;
	font-family: "微软雅黑";
}

p {
	margin-left: 5px;
	font-size: 14px;
}

body {
	height: 100%;
	overflow: hidden;
}

.filterPan td {
	padding: 0;
}

.mini-splitter-pane {
	overflow: auto;
}

.mini-panel-body {
	padding: 0;
}

html body .searchbox .mini-buttonedit-icon {
	background: url('<c:url value="/share/img/magnifier-zoom.png"></c:url>')
		no-repeat 5% 5%;
}

.nameTitle {
	color: red;
}

.cellclass {
	font-color: #000000;
	background-color: #FFEBE6;
	color: red;
}
.deepDark {
	background-color: #CCC488;
}

.normalDark {
	background-color: #FFF7BB;
}

.lowDark {
	
}
</style>
<script>
	var stateData = [ {
		id : "0",
		text : "暂无招聘"
	}, {
		id : "1",
		text : "正在招聘"
	} ];
</script>

</head>

<body>
	<div class="mini-toolbar"
		style="padding: 0px; border-width: 1px; border-bottom-width: 0px;">
		<table style="width: 100%;">
			<tr>
				<td style="width: 5px; height: 23px;"></td>
				<td width="300px"><a class="mini-button" id="addBtn"
					iconCls="icon-add" plain="true" onclick="add">新增</a><a
					class="mini-button" id="updateBtn" iconCls="icon-edit" plain="true"
					onclick="update">修改</a><a class="mini-button" id="deleteBtn"
					iconCls="icon-remove" plain="true" onclick="_delete()">删除</a><a
					class="mini-button" id="rebackBtn" plain="true" iconCls="icon-list"
					onclick="status1">返回列表</a></td>
				<td><span id="separatorId" class="separator"><a
						class="mini-button" id="resetBtn" iconCls="icon-reset"
						plain="true" onclick="reloadList">刷新</a>  </span></td>
				<td style="width: 80px; height: 100%;">
					<div class="pageStatContainer">
						<div id="pageStatBtn_list"
							class="pageStat pageStatList pageStatListPress">
							<p>1</p>
						</div>
						<div id="pageStatBtn_form" class="pageStat pageStatForm">
							<p>2</p>
						</div>
						<div id="pageStatBtn_split" class="pageStat pageStatSplit">
							<p>3</p>
						</div>
					</div>
				</td>
			</tr>
		</table>
	</div>
	<div class="mini-fit">
		<div id="splitterPan" class="mini-splitter"
			style="width: 100%; height: 100%;" handlerSize="0">
			<div id='panLeft' size="400" showCollapseButton="true"
				style="padding: 0px; height: 100%; width: 100%;">
				<div id="treegrid1" class="mini-treegrid"
					style="height: 100%; width: 100%;" showTreeIcon="true"
					borderStyle="border:1;" onbeforeload="treeBeforeLoad" pagesize="50"
					sizeList="[50,100,200,500]" showPager="false" treeColumn="OrgNo"
					idField="OrgNo" ondrawcell="ondatagridDrawCell"
					parentField="ParentNo" resultAsTree="false" expandOnLoad="true"
					showPageInfo="false" showFilterRow="true">
					<div property="columns">
						<div type="indexcolumn" width="40px"></div>
						<div type="checkcolumn" width="40px" align="center"></div>
						<div field="Action" width="70px" headerAlign="center"
							align="center">
							<a class="mini-button" property="filter" id="removeBtn"
								iconCls="icon-broom" tooltip="清除筛选" onclick="removeSearch()">清除
							</a>
						</div>
						<div name="OrgNo" field="OrgNo" width="200px" headerAlign="center"
							align="left" allowSort="true">
							企业编号<input id="filter1" property="filter"
								class="mini-buttonedit searchbox" style="width: 100%;"
								onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="OrgName" width="400px" headerAlign="center"
							align="left" allowSort="true">
							企业名称<input id="filter2" property="filter"
								class="mini-buttonedit searchbox" style="width: 100%;"
								onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="EmployState" width="80px" headerAlign="center"
							align="center" allowSort="true">
							招聘状态<input id="filter3" property="filter" class="mini-combobox"
								style="width: 100%;" data="stateData" onValueChanged="onselect"
								emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="EmployLink" width="300px" headerAlign="center"
							align="left" allowSort="true">招聘链接</div>
						<div field="EmployTime" width="185px"
							dateFormat="yyyy-MM-dd HH:mm" headerAlign="center" align="center"
							allowSort="true">预计招聘时间</div>
						<div name="emptyCol" width='100%' headerAlign="center"
							align="center" cellStyle="padding:0;"></div>
					</div>
				</div>
			</div>
			<div id="panRight" showCollapseButton="true" expanded="false"
				style="overflow: hidden;">
				<iframe id="detailPan" class="subPageFrame" frameborder="0">
				</iframe>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var isKeepStat3 = false;
		var rootPath = '${rootPath}';
		var filterHelper = gridFilter();
		var datagrid1 = mini.get("treegrid1");
		var splitpan = mini.get("splitterPan");
		var filter1 = mini.get("filter1");
		var filter2 = mini.get("filter2");
		var filter3 = mini.get("filter3");
		$(function() {
			$(".pageStat").hover(function() {
				$(this).addClass("hoverStyle");
			}, function() {
				$(this).removeClass("hoverStyle");
			});
			$(".pageStat").click(
					function() {
						$this = $(this);
						var value = $this.find("p").first().html();
						if (value == 1) {
							splitpan.collapsePane(2);
							$this.addClass("pageStatListPress");
							$this.next().removeClass("pageStatFormPress")
									.next().removeClass("pageStatSplitPress");
							isKeepStat3 = false;
							status1Show();
						}
						if (value == 2) {
							splitpan.collapsePane(1);
							$this.addClass("pageStatFormPress");
							$this.prev().removeClass("pageStatListPress");
							$this.next().removeClass("pageStatSplitPress");
							isKeepStat3 = false;
							status2Show();
						}
						if (value == 3) {
							splitpan.expandPane(1);
							splitpan.expandPane(2);
							$this.addClass("pageStatSplitPress");
							$this.prev().removeClass("pageStatFormPress")
									.prev().removeClass("pageStatListPress");
							isKeepStat3 = true;
							status3Show();
						}
					});
			status1();
			loadGrid1();
		});
		//双击
		function gridRowDbClick(e) {
			/* var id = e.row.id;
			showDetail(id); */
		}
		function showDetail(id) {
			status2();
			$('#detailPan').css('height', '100%').css('width', '100%').attr(
					'src', '<c:url value="/source/sourceForm/" />' + id);
		}
		function onselect() {
			var filterValue1 = filter1.getValue();
			var filterValue2 = filter2.getValue();
			var filterValue3 = filter3.getValue();
			filterHelper.clearFilterData();
			if (filterValue1 != "") {
				var filterdata = filterHelper.formFilterData("OrgNo",
						filterValue1, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue2 != "") {
				var filterdata = filterHelper.formFilterData("OrgName",
						filterValue2, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue3 != "") {
				var filterdata = filterHelper.formFilterData("EmployState",
						filterValue3, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			loadGrid1();
		}
		function loadGrid1() {
			var filterData = filterHelper.getFilterData();
			var postData = new Object();
			if (filterData != null || filterData.length > 0) {
				postData.filterdata = mini.encode(filterData);
			}
			var url = "<c:url value='/org/list' />" ;
			datagrid1.setUrl(url);
			datagrid1.load(postData);
		}
		function removeSearch() {
			filter1.setValue();
			filter1.setText();
			filter2.setValue();
			filter2.setText();
			filter3.setValue();
			filterHelper.clearFilterData();
			loadGrid1();
		}

		function status1() {
			if (!isKeepStat3) {
				$("#pageStatBtn_list").click();
			}
		}
		function status2() {
			if (!isKeepStat3) {
				$("#pageStatBtn_form").click();
			}
		}
		function status3() {
			$("#pageStatBtn_split").click();
		}
		function status1Show() {
			$('#rebackBtn').hide();
			$('#resetBtn').show();
			$("#addBtn").show();
			$("#updateBtn").show();
			$("#deleteBtn").show();
			$("#separatorId").show();
		}
		function status2Show() {
			$('#rebackBtn').show();
			$('#resetBtn').hide();
			$("#addBtn").hide();
			$("#updateBtn").hide();
			$("#deleteBtn").hide();
			$("#separatorId").hide();
		}
		function status3Show() {
			$('#rebackBtn').hide();
			$('#resetBtn').show();
			$("#addBtn").hide();
			$("#updateBtn").hide();
			$("#deleteBtn").hide();
			$("#separatorId").show();
		}
		function reloadList() {
			datagrid1.reload();
		}

		function add() {
			status2();
			$('#detailPan').css('height', '100%').css('width', '100%').attr(
					'src', '<c:url value="/org/add" />');
		}
		function update() {
			var row = datagrid1.getSelected();
			if(!row){
				mini.alert('请选择要修改的企业！');
				return;
			}
			var orgNo = row.OrgNo;
			if(!orgNo){
				mini.alert('企业数据有误，请联系管理员处理！');
				return;
			}
			status2();
			$('#detailPan').css('height', '100%').css('width', '100%').attr(
					'src', '<c:url value="/org/edit/" />'+orgNo);
		}
		function _delete() {
			var row = datagrid1.getSelected();
			if (!row) {
				mini.alert("请选择！");
				return;
			}
			var children = row.children;
			if(children && children.length > 0){
				mini.alert("该企业存在下属企业，不能删除！");
				return;
			}
			mini.confirm("确定删除？", "确定？", function(action) {
				if (action == "ok") {
					var url = rootPath + "/org/delete/"+row.OrgNo;
					$.ajax({
						url : url,
						method : "post",
						dataType : "json",
						data : {
						},
						success : function(data) {
							if (data.isSuccess) {
								top.commonTools.showTip("操作成功！", 1);
								datagrid1.reload();
							} else if (data.errorInfo) {
								top.commonTools.showTip("删除失败！", 2);
							}
						},
						error : function() {
							top.commonTools.showTip("删除失败！", 2);
						}

					});
				}
			});
		}
		function treeBeforeLoad(e) {
			var filterData = filterHelper.getFilterData();
			e.data.filterdata = mini.encode(filterData);
		}
		function ondatagridDrawCell(e) {
			var field = e.field;
			var row = e.row;
			var grade = row.Grade;
			var cellCls = null;
			switch (grade) {
			case 1:
				cellCls = "deepDark";
				break;
			case 2:
				cellCls = "normalDark";
				break;
			default:
				cellCls = "lowDark";
				break;
			}
			e.cellCls = cellCls;
			if(field == "EmployState"){
				var value = e.value;
				var text = stateData[e.value].text;
				if(value == 1 || value == '1'){
					e.cellHtml = '<span style="color:red">'+text+'</span>';
				}else{
					e.cellHtml = text;
				}
			}
			if (field == "EmployLink") {
				var value = e.value;
				if(value){
					if(!value.includes('http')){
						value = "http://" +value;
					}
					e.cellHtml = '<a target="_blank" class="aTagUnderLine" href="'+value+'">'+value+'</a>';
				}
			}
			if (field == "Action") {
				var orgNo = row.OrgNo;
				e.cellHtml = '<a class="aTagUnderLine" href="javascript:check(\''
						+ orgNo + '\')">[企业详细]</a>';
			}
		}
		function check(orgNo){
			status2();
			$('#detailPan').css('height', '100%').css('width', '100%').attr(
					'src', '<c:url value="/org/edit/" />'+orgNo);
		}
	</script>
</body>
</html>